This replication package contains the PFCRE R package, scripts to conduct the simulations in the main text and appendix, as well as the data and scripts for the applications. 

The scripts for simulations take a substantial amount of computing time in a standard computer Windows with 8 cores (up to several days, if all simulations are included). The simulations are not set with a seed, therefore replications will produce similar but not identical results. 

The scripts for the applications should run in under 15 minutes (or even less, depending on the processor). 

Below I describe the different files included in this replication package and the relationships to each other. Towards the end details of R and package versions used is included. 

1. The PFCRE R package. Requires R 3.6.1 (does not function in newer versions). 
	The PFCRE R package is available in two forms, as Source and as Binary. 
	PFCRE_0.1.0 is the PFCRE package in Binary form. Can be installed by selecting Tools > Install Packages
	PFCRE_0.1.0.tar.gz is the tarball of the PFCRE package in Soruce form. 

2. R scripts for the main simulations
	Main_Simulations_Summary.R conducts the summary of the simulations results. Creates figures 2, 3, and 4 in paper.
	Main_Board.R conducts the simulations and stores results
	sims_function.R creates the simulated data for main simulations and conducts estimations. 

	For Specification Test simulations: 
	simsHT_function.R creates simulated data for specification test simulations and estimation (F5 and F6) 
	Main_Board_HT.R conducts the simulations for the specification test and stores results.
	Main_Board_HT2.R identical to previous one, generating additional simulations 
	Simulations_Summary_HT.R produces the summary of specification test simulation results. Creates figure F5 and  F6 in the paper. 
	

3. R scripts for all appendix simulations
   a. Appendix A
	Summary_fcre.R conducts the summary of the simulation results for the comparison of PF-CRE, F-CRE, and the Oracle, presented in Figures FA1, FA2, and FA3 in Appendix A. Requires the output from Main_Board_time_fcre.R
	Main_Board_time_fcre.R produces the simulations for Appendix A and B1. Requires sims_function_time_fcre.R
	sims_function_time_fcre.R simulates data and estimates models for results presented in Appendix A and B1. 

   b1. Appendix B1
	Summary_times.R conducts the summary of the simulation results for computational times presented in Appendix B1 (Table TB1). Requires the output from Main_Board_time_fcre.R
	Main_Board_time_fcre.R produces the simulations for Appendix A and B1. Requires sims_function_time_fcre.R
	sims_function_time_fcre.R simulates data and estimates models for results presented in Appendix A and B1. 	

   b2. Appendix B2
	Main_Board_Coverage.R produces the simulations for Appendix B2 and produces the summary of coverage probabilities presented in Table B2. Requires sims_function_coverage.R

   c. Appendix C
	Simulations_Summary_RE.R conducts the summary of the simulations results for rare-events data presented in Appendix C, Figure C1. Requires the output from Main_Board_RE.R
	Main_Board_RE.R produces the simulations for Appendix C. Requires sims_function_RE.R
	sims_function_RE.R simulates data and estimates models for rare-events results presented in Appendix C. 

   d. Appendix D
	Simulations_Summary_vio.R conducts the summary of the simulation results for when the exchangeability assumption is violated, presented in Appendix D, Figure D1. Requires the output from Main_board_vio.R
	Main_Board_vio.R produces the simulations for Appendix D. Requires sims_function_vio.R
	sims_function_vio.R simulates data and estimates models for when the exchangeability assumption is violated, presented in Appendix D. 	

   e. Appendix E 
	Simulations_Summary_HTOR.R conducts the summary of the simulation results for the specification test for the Oracle estimator only, presented in Appendix E. Requires Main_Board_HT_Oracle.R
	Main_Board_HT_Oracle.R produces the simulations for Appendix E. REquires sims_HT_Oracle_Only.R
	sims_HT_Oracle_Only.R simulates data and estimates the Oracle model for the specification test for the Oracle estimator presented in Appendix E. 
 
4. Data and scripts for BES application
	TacticalVotingApplication.R produces the results for the application on tactical voting in the 2015 UK General Election, figure 7 and 8 in the text and Table F1 in Appendix F. 
	ImputedData2015.Rdata contains the recoded and imputed data for the tactical voting application based on the British Election Online Study Panel. 


5. Data and scripts for Marinov replication 
	Marinov_Replication.R produces the results for the application that replicates Marinov (2005), figures F9 and F10 in the text and Table F2 in Appendix F. 
	marinov_ldpaper.dta contains the data from Marinov (2005) used to replicate those results. 


R, OS, and Packages information
All the simulations and applications were conducted using R version 3.6.1 running on Windows 10, 64-bit. 

The following are the attached packages used and their versions: 
xtable        1.8-4
dplyr         0.8.5       
margins       0.3.23    
lfe           2.8-3         
Matrix        1.2-17     
bife          0.7          
ggplot2       3.2.1     
gridExtra     2.3    
mice          3.5.0        
lattice       0.20-38   
survival      2.44-1.1 
readstata13   0.9.2 
PFCRE         0.1.0    
data.table    1.12.2
reshape2      1.4.3
optimx        2018-7.10  
lme4          1.1-21       
alpaca        0.3.2      
pglm          0.2-1        
plm           2.0-1         
maxLik        1.3-6      
miscTools     0.6-22  
MASS          7.3-51.4 

The following packages are loaded via a namespace (and not attached): 
mitml         0.3-7        
Rcpp          1.0.1         
bdsmatrix     1.3-3    
tidyr         1.0.2        
zoo           1.8-6          
assertthat    0.2.1   
lmtest        0.9-37     
R6            2.4.0           
plyr          1.8.4         
pan           1.6            
backports     1.1.4    
jomo          2.6-8         
pillar        1.4.3       
Rdpack        0.11-0     
rlang         0.4.6        
lazyeval      0.2.2     
rstudioapi    0.11    
minqa         1.2.4        
nloptr        1.2.1       
rpart         4.1-15       
splines       3.6.1     
statmod       1.4.32     
stringr       1.4.0      
munsell       0.5.0      
broom         0.5.2        
compiler      3.6.1     
numDeriv      2016.8-1  
pkgconfig     2.0.2   
nnet          7.3-12        
tidyselect    0.2.5   
tibble        2.1.3       
crayon        1.3.4       
withr         2.1.2        
grid          3.6.1         
nlme          3.1-140      
gtable        0.3.0       
lifecycle     0.1.0    
magrittr      1.5       
scales        1.0.0       
bibtex        0.4.2       
stringi       1.4.3      
generics      0.0.2    
vctrs         0.2.3        
boot          1.3-22        
sandwich      2.5-1     
Formula       1.2-3      
prediction    0.3.6.2 
tools         3.6.1        
glue          1.4.1        
purrr         0.3.3        
yaml          2.2.0         
colorspace    1.4-1   
gbRd          0.4-11    